/*
 * Copyright (c) 2008, 2016, OneAPM and/or its affiliates. All rights reserved.
 */
package me.yufan.chess.ui;

import me.yufan.chess.operation.ErrorHandler;

import javax.swing.*;

/**
 * Title: UI
 * Description:
 *
 * @author Yufan
 * @version 1.0.0
 * @since 2016-01-26 22:55
 */
public class UI {

    private UI() {
        // This class should not be instantiated.
    }

    /**
     * Shows a confirmation dialog (used before exiting the game).
     *
     * @param message the message to display
     * @return true if user selects "yes", false otherwise
     */
    public static boolean showExitConfirmation(String message) {
        try {
            UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
        } catch (Exception e) {
            ErrorHandler.error("Could not set system look and feel for exit confirmation.", e);
        }
        int n = JOptionPane.showConfirmDialog(null, message, "Warning", JOptionPane.YES_NO_OPTION,
            JOptionPane.WARNING_MESSAGE);
        return n != JOptionPane.YES_OPTION;
    }
}
